package com.me.launcher.bean;

import android.content.pm.ActivityInfo;
import android.support.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import static com.me.launcher.bean.AppBean.AppType.LAUNCH_APP;
import static com.me.launcher.bean.AppBean.AppType.LAUNCH_SHORT_CUT;

public class AppBean {
    int appType;
    String strName;
    ActivityInfo activityInfo = null;
    String intent;
    private String pkgName;


    public AppBean(Builder userBuilder) {
        this.appType = userBuilder.appType;
        this.strName = userBuilder.strName;
        this.pkgName = userBuilder.pkgName;
        this.activityInfo = userBuilder.activityInfo;
        this.intent = userBuilder.intent;
    }

    public String getStrName() {
        return strName;
    }

    public void setStrName(String strName) {
        this.strName = strName;
    }

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public void setActivityInfo(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public String getIntent() {
        return intent == null ? "" : intent;
    }

    public void setIntent(String intent) {
        this.intent = intent;
    }

    public int getAppType() {
        return appType;
    }

    public void setAppType(int appType) {
        this.appType = appType;
    }

    public String getPkgName() {
        return pkgName == null ? "" : pkgName;
    }

    public void setPkgName(String pkgName) {
        this.pkgName = pkgName;
    }

    @Override
    public String toString() {
        return "AppBean{" +
                "appType=" + appType +
                ", strName='" + strName + '\'' +
                ", activityInfo=" + activityInfo +
                ", intent='" + intent + '\'' +
                ", pkgName='" + pkgName + '\'' +
                '}';
    }

    @IntDef({LAUNCH_APP, LAUNCH_SHORT_CUT})
    @Retention(RetentionPolicy.SOURCE)
    public @interface AppType {
        public static final int LAUNCH_APP = 1;
        public static final int LAUNCH_SHORT_CUT = 2;//对应使用我的多开app建立的桌面快捷方式

    }

    public static class Builder {
        private int appType;
        private String strName;
        private String pkgName;
        private ActivityInfo activityInfo;
        private String intent;

        public Builder name(String strName) {
            this.strName = strName;
            return this;
        }

        public Builder pkgname(String pkgName) {
            this.pkgName = pkgName;
            return this;
        }

        public Builder activityInfo(ActivityInfo activityInfo) {
            this.activityInfo = activityInfo;
            return this;
        }

        public Builder intent(String intent) {
            this.intent = intent;
            return this;
        }

        public Builder type(@AppType int appType) {
            this.appType = appType;
            return this;
        }

        public AppBean build() {
            return new AppBean(this);
        }
    }
}
